package com.itwlj.controller.user;

import com.itwlj.result.Result;
import com.itwlj.service.GoodsService;
import com.itwlj.vo.GoodsDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取商品详情
 */
@RestController
@RequestMapping("/goods")
@Api(tags = "C端商品相关接口")
@Slf4j
public class GoodsDetailController {
    @Autowired
    private GoodsService goodsService;

    /**
     * 获取商品详情
     *
     * @param id
     * @return
     */
    @GetMapping
    @ApiOperation("获取商品详情")
    public Result<GoodsDetailVO> getGoodsInfo(Long id) {
        log.info("获取商品详情：{}", id);
        GoodsDetailVO goodsDetailVO = goodsService.getById(id);
        return Result.success(goodsDetailVO);
    }
}
